package com.chinasofti.tcp03;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10000);

        Socket accept = ss.accept();

        //网络中的流，从客户端获取数据
        BufferedInputStream bis = new BufferedInputStream(accept.getInputStream());

        //将图片，写到本地
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("java423\\copy.png"));

        int b;
        while((b = bis.read()) != -1){
            bos.write(b);
        }
        //提示客户端  上传成功
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bw.write("上传成功！");
        bw.newLine();
        bw.flush();

        bos.close();
        accept.close();
        ss.close();
    }
}